﻿#include <iostream>
#include <string>
#include <stack>
using namespace std;

int main()
{
    setlocale(LC_ALL, "Russian");
    deque<char> dequeData;
    string br;
    bool IsBalanced = true;
    cout << "Введите скобки:";
    getline(cin, br);
    for (char sym : br)
        switch (sym)
        {
            case '(':
            case '[':
            case '{':
            case '<':
                dequeData.push_back(sym);
                break;
            case ')':
                if (dequeData.empty() || dequeData.back() != '(')
                    IsBalanced = false;
                else
                    dequeData.pop_back();
                break;

            case ']':
                if (dequeData.empty() || dequeData.back() != '[')
                    IsBalanced = false;
                else
                    dequeData.pop_back();
                break;
            case '}':
                if (dequeData.empty() || dequeData.back() != '{')
                    IsBalanced = false;
                else
                    dequeData.pop_back();
                break;
            case '>':
                if (dequeData.empty() || dequeData.back() != '<')
                    IsBalanced = false;
                else
                    dequeData.pop_back();
                break;
        }
    if (IsBalanced == false || !dequeData.empty())
        cout << "False";
    else
        cout << "True";
        
}


